package com.csx.micrometer.sentinel.core;

import com.alibaba.csp.sentinel.context.Context;
import com.alibaba.csp.sentinel.node.DefaultNode;
import com.alibaba.csp.sentinel.slotchain.AbstractLinkedProcessorSlot;
import com.alibaba.csp.sentinel.slotchain.ResourceWrapper;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author cuisongxu
 * @date 2022/11/20 21:55
 */
public class MySlot extends AbstractLinkedProcessorSlot<DefaultNode> {

    private final Map<String,DefaultNode> defaultNodeMap = new ConcurrentHashMap<>();

    @Override
    public void entry(Context context, ResourceWrapper resourceWrapper, DefaultNode node, int count, boolean prioritized, Object... args) throws Throwable {
        fireEntry(context, resourceWrapper, node, count, prioritized, args);
        defaultNodeMap.put(resourceWrapper.getName(), node);

    }

    public Map<String,DefaultNode> getDefaultNodeMap() {
        return defaultNodeMap;
    }

    @Override
    public void exit(Context context, ResourceWrapper resourceWrapper, int count, Object... args) {

    }


}
